﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testing_thing
{
    public class LookCommand : Command
    {
        public LookCommand()
            : base(new string[] { "look", "where am i", "look at", "look in", "look at in" })
        {
        }

        public override string Run(Player p, string[] input)
        {
            if (input.Length == 1 && input[0] == "look") return DoLook(p);
            else if (input.Length == 3 && input[0] == "where" && input[1] == "am" && input[2] == "i") { return WhereAmI(p); }
            else if (input.Length == 3 && input[0] == "look" && input[1] == "at") { return DoLookAt(p, input[2]); }
            else if (input.Length == 3 && input[0] == "look" && input[1] == "in") { return DoLookIn(p, input[2]); }
            else if (input.Length == 5 && input[0] == "look" && input[1] == "at" && input[3] == "in") { return DoLookAtIn(p, input[2], input[4]); }




            return "I don't know how to look like that...";
        }

        private string DoLook(Player p)
        {
            return p.InLocation.LongDescription + p.InLocation.PathList;
        }

        private string DoLookAt(Player p, string id)
        {
            GameEntity item = p.LocateEntity(id);
            if (item != null)
            {
                return item.Description;
            }
            else return "I can't find " + id;
        }
        private string DoLookIn(Player p, string id)
        {
            GameEntity item = p.LocateEntity(id);
            if (item != null)
            {
                return item.LongDescription;
            }
            return "I can't find" + id;
        }
        private string WhereAmI(Player p)
        {
            return p.InLocation.Title;
        }

        private string DoLookAtIn(Player p, string id, string containderId)
        {
            GameEntity container = p.LocateEntity(containderId);
            if (container != null)
            {
                GameEntity item = container.LocateEntity(id);
                if (item != null)
                    return item.Description;
                ;

            }
            return "There is no" + id + "in" + containderId;


        }
    }
}